<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <h2>
        {{totalPrice}}
    </h2>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script>
    let app = new Vue({
        el: '#app',
        data: {
            books: [
                {id: 1, name: 'Java', price: 111},
                {id: 2, name: 'PHP', price: 111},
                {id: 3, name: 'HTML', price: 111},
                {id: 4, name: 'SQL', price: 111}
            ]
        },
        computed: {
            totalPrice: function () {
                let result = 0
                for (let i = 0; i < this.books.length; i++) {
                    result += this.books[i].price
                }
                return result
            },

        }
    })
</script>
</body>
</html>
